package cn.toma.core.web;

import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author zqx
 * @version 1.0.0
 * @ClassName SwaggerConfiguration.java
 * @Description
 * @createTime 2019年09月20日 13:45:00
 */
@Configuration
@EnableSwagger2
@EnableSwaggerBootstrapUI
public class SwaggerConfiguration
{


	@Bean
	public Docket createRestApi()
	{
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(apiInfo())
				.groupName("默认接口")
				.select()
				.apis(RequestHandlerSelectors.basePackage("cn.toma.controller"))
				.paths(PathSelectors.any())
				.build();
	}

	private ApiInfo apiInfo()
	{
		return new ApiInfoBuilder()
				.title("API")
				.description(" 接口文档")
				.termsOfServiceUrl("http://localhost:8080/")
				.version("1.0")
				.build();
	}
}
